package cn.com.dbappsecurity.controller;

import java.util.List;

import cn.com.dbappsecurity.frame.annotations.Action;
import cn.com.dbappsecurity.frame.annotations.Controller;
import cn.com.dbappsecurity.frame.annotations.Log;
import cn.com.dbappsecurity.frame.datamodal.GridDataModal;
import cn.com.dbappsecurity.frame.datamodal.IDataModal;
import cn.com.dbappsecurity.service.ILog;
import cn.com.dbappsecurity.service.impl.LogImpl;

@Controller("log")
public class LogController extends BaseController{
	
	private ILog logService = getService(LogImpl.class);
	
	@Log(value="查询日志",entry={"dateFrom=日期从","dateTo=日期到","status=状态","username=用户名","ip=IP地址","event=操作类型"})
	@Action
	public IDataModal search(String dateFrom,String dateTo,Integer status,
			String username,String ip,String event,int page,
			int rows,String sort,String order) throws Exception{
		
		int total = logService.searchCount(dateFrom, dateTo, status, username, ip, event);
		List<cn.com.dbappsecurity.entity.Log> data = null;
		if(total > 0){
			data = logService.search(dateFrom, dateTo, status, username, ip, event, page, rows, sort, order);
		}
		IDataModal modal = new GridDataModal(total, data);
		return modal;
	}
	
}
